package viewHandler;

import com.webservice.ParkingPassesBean;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;


/**
 * @author <a href="mailto:gesuino.napoli">Gesuino Napoli</a>
 *
 */
public class MyViewHandlerWrapper extends ViewHandlerWrapper {

    private ViewHandler wrapped;

    public MyViewHandlerWrapper(ViewHandler wrapped) {
    this.wrapped = wrapped;
    }

    @Override
    public ViewHandler getWrapped() {
        return this.wrapped;
    }

    @Override
    public String calculateRenderKitId(FacesContext context) {
        HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
        String userAgent = req.getHeader("user-agent");
        String accept = req.getHeader("Accept");

        if (userAgent != null && accept != null) {
            UAgentInfo agent = new UAgentInfo(userAgent, accept);
            if (agent.isMobileDevice()) {
             
                return "PRIMEFACES_MOBILE";
            }
        }

        return this.wrapped.calculateRenderKitId(context);
    }
    
    
    
      public void serverLog(String x) {
 
    }
}